 const arr = [[1, 2, 3, [4,5], 6], 7, 8, [9, 10]];
/* let result = [];
 数组扁平化
const flattenArray = (arr) => {
    arr.forEach(element => {
        if (Array.isArray(element)) {
            flattenArray(element)
        } else {
            result.push(element)
        }
    })
    return result  
}
console.log(flattenArray(arr)); */  //!问题在于有外部变量result

const flattenArray = (arr) => {
    let result=[]
    arr.forEach(element => {
        if (Array.isArray(element)) {
            result.push(...flattenArray(element))
        } else {
            result.push(element)
        }
    })
    return result  
}
console.log(flattenArray(arr));
